<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>善禾园</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <style>
        * {
            padding: 0;
            margin: 0;
            overflow: hidden;
        }

        #btn {
            font-size: 32px;
            width: 100%;
            height: 100vh;
            background: url("./unloads.png") no-repeat;
            background-size: 100% 100%;
            overflow: hidden;
        }
        #btn_weapper{
            width: 100%;
            height: 100%;
            position: fixed;
            bottom: 0px;
            left: 0px;
        }
        #btn1{
            width: 100%;
            height: 100%;
        }
        /* #btn2{
            width: 100%;
            height: 50%;
        } */


        button {
            font-size: 80px;
            margin: 50px;
        }


        #WXShadow {
            display: none;
            width: 100%;
            height: 100vh;
            background: rgba(0, 0, 0, 0.7);
            position: fixed;
            top: 0;
            z-index: 3;
        }

        .texts {
            font-size: 1.5rem;
            color: #FFFFFF;
            position: fixed;
            top: 6rem;
            width: 100%;
            text-align: right;
            font-weight: 600;
            right: 10%;
        }

        img {
            /*position: fixed;*/
            /*top: 8rem;*/
            /*right: 5.5rem;*/
            width: 37px;

        }

    </style>
</head>
<body>
<div style="width: 100%; overflow: hidden;" >
    <div id="btn">
        <div id="btn_weapper">
            <div id="btn1"></div>
            <div id="btn2"></div>
        </div>
    </div>

    <div id="WXShadow" onclick="clostToi()">

        <div class="texts">
            请在浏览器中打开
            <img src="./jiantous.png"/>
        </div>

    </div>
</div>

</body>
<script>
    var baseUrl = ''
    function clostToi() {
        document.getElementById('WXShadow').style.display = "none"
    }

    // 检查是否安装app
    function openApp(e) {
        var u = window.navigator.userAgent;

        if (/MicroMessenger/gi.test(u)) {

            document.getElementById('WXShadow').style.display = "block"
            return;
        }

        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        if (isAndroid) {
            android();
        }
        if (isiOS) {
            alert('开发中，敬请期待！！！');
            // ios();
        }
    }

    function android() {
        var _clickTime = new Date().getTime();

        //启动间隔20ms运行的定时器，并检测累计消耗时间是否超过3000ms，超过则结束
        var _count = 0, intHandle;
        intHandle = setInterval(function () {
            _count++;
            var elsTime = new Date().getTime() - _clickTime;
            if (_count >= 100 || elsTime > 3000) {

                clearInterval(intHandle);
                //检查app是否打开
                if (document.hidden || document.webkitHidden) {
                    // 打开了
                    window.close();
                } else {
                    // 没打开
                    // alert('没打开')
                    window.location.href = baseUrl;//下载链接
                }
            }
        }, 20);

    }

    function ios() {
        var _clickTime = +(new Date());
        var ifr = document.createElement("iframe");
        ifr.src = "？？？？？？？？？？？？？？";
        /***打开app的协议，有ios同事提供***/
        ifr.style.display = "none";
        document.body.appendChild(ifr);
        //启动间隔20ms运行的定时器，并检测累计消耗时间是否超过3000ms，超过则结束
        var _count = 0, intHandle;
        intHandle = setInterval(function () {
            _count++;
            var elsTime = +(new Date()) - _clickTime;
            console.log(_count, elsTime, +(new Date()), _clickTime)
            if (_count >= 100 || elsTime > 3000) {
                clearInterval(intHandle);
                document.body.removeChild(ifr);
                //检查app是否打开
                if (document.hidden || document.webkitHidden) {
                    // 打开了
                    window.close();
                } else {
                    // 没打开
                    alert('没打开')
                    // window.location.href = "？？？？？？？？？？？？？？？";//下载链接
                }
            }
        }, 20);
    }

    var objbtn1 = document.getElementById('btn1');

    objbtn1.onclick = function () {
        baseUrl = 'http://app.shanheyuansc.com/down/shanheyuan.apk'
        openApp()
    }
    // objbtn2.onclick = function () {
    //     baseUrl = 'https://wxt.qyscyf.com/down/chuzuche.apk'
    //     openApp()
    // }

</script>
</html>